ssssss
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
	</body>
	<script>
		//以下是未应用策略模式
		class User {
			constructor(type) {
				this.type = type
			}
			buy() {
				if(this.type === 'ordinary') {
					console.log('普通用户购买')
				} else if(this.type === ' member') {
					console.log('会员用户购买')
				} else if(this.type ===
					'vip') {
					console.log('vip用户购买')
				}
			}
		}
		//测试代码
		var u1 = new User('ordinary')
		u1.buy()
		var u2 = new User(' member')
		u2.buy()
		var u3 = new User('vip')
		u3.buy()

		//以下是应用策略模式
		class OrdinaryUser {
			buy() {
				console.log('普通用户购买')
			}
		}
		class MemberUser {
			buy() {
				console.log('会员用户购买')
			}
		}
		class VipUser {
			buy() {
				console.log('vip用户购买')
			}
		}

		var u1 = new OrdinaryUser()
		u1.buy()
		var u2 = new MemberUser()
		u2.buy()
		var u3 = new VipUser()
		u3.buy()
	</script>

</html>